package cn.iocoder.yudao.module.api.trade.order.enums;

import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;

/**
 * 交易订单 - 类型
 *
 * @author Sin
 */
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
@RequiredArgsConstructor
@Getter
public enum TradeOrderTypeEnum implements ArrayValuable<Integer> {

    NORMAL(0, "普通订单"),
    SECKILL(1, "秒杀订单"),
    BARGAIN(2, "砍价订单"),
    COMBINATION(3, "拼团订单"),
    POINT(4, "积分兑换订单"),
    CRYPTOCURRENCY(5, "联盟豆兑换订单"),
    GROUPON(6, "团购订单"),

    LINKAGE_N_1(8, "链动订单"),
    INVITE_N_REBATE(9, "返本订单"),

    TAKE_AWAY(10, "外卖订单"),
    FOOD(20, "美食订单"),
    HOTEL(30, "酒店订单"),
    ENTERTAINMENT(40, "娱乐订单"),
    HOUSEKEEPING(50, "家政订单"),
    SCENIC(60, "景区订单"),
    GIFT(999, "赠品订单"),
    ;

    public static final Integer[] ARRAYS = Arrays.stream(values()).map(TradeOrderTypeEnum::getType).toArray(Integer[]::new);

    /**
     * 类型
     */
    @EnumValue
    private final Integer type;
    /**
     * 类型名
     */
    private final String name;

    public static TradeOrderTypeEnum getByType(Integer type) {
        return Arrays.stream(values()).filter(item -> ObjectUtil.equal(type, item.getType()))
                .findFirst().orElse(NORMAL);
    }

    @Override
    public Integer[] array() {
        return ARRAYS;
    }

    public static boolean isNormal(Integer type) {
        return ObjectUtil.equal(type, NORMAL.getType());
    }

    public static boolean isSeckill(Integer type) {
        return ObjectUtil.equal(type, SECKILL.getType());
    }

    public static boolean isBargain(Integer type) {
        return ObjectUtil.equal(type, BARGAIN.getType());
    }

    public static boolean isCombination(Integer type) {
        return ObjectUtil.equal(type, COMBINATION.getType());
    }

    public static boolean isPoint(Integer type) {
        return ObjectUtil.equal(type, POINT.getType());
    }

    public static boolean isTakeAway(Integer type) {
        return ObjectUtil.equal(type, TAKE_AWAY.getType());
    }

    public static boolean isFood(Integer type) {
        return ObjectUtil.equal(type, FOOD.getType());
    }

    public static boolean isHotel(Integer type) {
        return ObjectUtil.equal(type, HOTEL.getType());
    }

    public static boolean isEntertainment(Integer type) {
        return ObjectUtil.equal(type, ENTERTAINMENT.getType());
    }

    public static boolean isHousekeeping(Integer type) {
        return ObjectUtil.equal(type, HOUSEKEEPING.getType());
    }

}
